//
//  MainTabBarController.swift
//  swiftDemo
//
//  Created by 众力金融 on 2018/8/28.
//  Copyright © 2018年 众力金融. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let tabBar = UITabBar.appearance()
        tabBar.tintColor = UIColor.QXTabBarItemtintColor
      addChildViewControllers()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    
    }

}

extension MainTabBarController {
    fileprivate func addChildViewControllers() {
        addChildViewController(childController: ZLHomeVc(), title: "单糖", imageName: "TabBar_home_23x23_")
        addChildViewController(childController: ZLHomeVc(), title: "单品", imageName: "TabBar_gift_23x23_")
        addChildViewController(childController: ZLHomeVc(), title: "分类", imageName: "TabBar_category_23x23_")
        addChildViewController(childController: ZLHomeVc(), title: "我的", imageName: "TabBar_me_boy_23x23_")
    }
    
    /// 初始化子控制器
    ///
    /// - Parameters:
    ///   - childController: 需要初始化的控制器
    ///   - title: 标题
    ///   - imageName: 图片的名称
    fileprivate func addChildViewController(childController: UIViewController, title: String, imageName: String) {
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "selected")
        childController.title = title
        let nacV = BaseNavigationController(rootViewController: childController)
        addChildViewController(nacV)
        // childController.tabBarItem.selectedImage = UIImage(named: selImage)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        
    }
}
